#include<iostream>
#include<cstdlib>
#include<cstring>
#include<vector>
using namespace std;
class ComplexNumber
{
public:
	ComplexNumber(int aa,int bb):a(aa),b(bb)
	{
	}
	bool operator>(const ComplexNumber m)
	{
		if(a*a+b*b>m.a*m.a+m.b*m.b)return 1;
		else if(a*a+b*b==m.a*m.a+m.b*m.b&&b<m.b)return 1;
		else return 0;
	}
	int a,b;
};
void Pop(vector<ComplexNumber> &number)
{
	if(number.empty())cout<<"empty"<<endl;
	else
	{
		ComplexNumber temp=*number.begin();
		vector<ComplexNumber>::iterator whereis=number.begin();
		for(vector<ComplexNumber>::iterator p=number.begin();p!=number.end();p++)
		{
			if(*p>temp)
			{	
				temp=*p; 
				whereis=p; 
			}
		}
		cout<<(*whereis).a<<"+i"<<(*whereis).b<<endl;
		number.erase(whereis);
		cout<<"SIZE = "<<number.size()<<endl;
	}
}
int Insert(vector<ComplexNumber> &number,char *str)
{
	char a[10],b[10];
	int i;
	for(i=0;str[i]!='+';i++)a[i]=str[i];
	a[i]=0;
	int j;
	for(j=0,i=i+2;str[i]!=0;i++,j++)b[j]=str[i];
	b[j]=0;
	ComplexNumber num(atoi(a),atoi(b));
	number.push_back(num);
	return number.size();
}
int main()
{
	int n;
	char str[15];
	vector<ComplexNumber> number;
	while(cin>>n)
	{
		while(n--)
		{
			cin>>str;
			if(strcmp(str,"Pop")==0)
				Pop(number);
			else 
			{
				cin>>str;
				cout<<"SIZE = "<<Insert(number,str)<<endl;
			}
			for(int i=0;i<15;i++)str[i]=0;
		}
	}
	return 0;
}